-
Notifications
You must be signed in to change notification settings - Fork 424
feat: Windows support #2119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Windows support #2119
Conversation
|
Very interesting, I had no idea that lld could link MinGW and MSVC objects together. This links against |
|
Mingw isn't used at all with this patch. Everything uses Visual Studio.
Locally, I even manage to run I also have a patch for Static PHP CLI, but it's not working because the PHP source code and Makefile on Windows doesn't support building a static version of |
That's the part I was missing, thank you! |
|
Gave it a shot and updated your initial post for instructions, however, once it attempts to serve a php file with |
|
Have you copied all the necessary DDLs in the same directory? |
|
Shouldn't be necessary with $env:PATH += ";$env:VCPKG_ROOT\installed\x64-windows\bin"
$env:PATH += ";C:\watcher-x86_64-pc-windows-msvc"
$env:PATH += ";C:\php-8.5.1-Win32-vs17-x64"Is anything else required? |
|
You must also add |
|
Same issue, I don't think it could be related to libraries anyway, as it would fail to run in the first place then. Shared libraries are (by default) loaded at initialisation time and we're not passing delayload arguments to the compilation. Log: ❯❯ frankenphp git:(windows) 21:46 .\frankenphp.exe php-server --root=./
2026/01/10 20:46:22.912 WARN admin admin endpoint disabled
2026/01/10 20:46:22.912 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0x2e61d3850500"}
2026/01/10 20:46:22.912 WARN http.auto_https server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server {"server_name": "php", "http_port": 80}
2026/01/10 20:46:22.949 INFO frankenphp FrankenPHP started 🐘 {"php_version": "8.5.1", "num_threads": 64, "max_threads": 64}
2026/01/10 20:46:22.950 WARN http HTTP/2 skipped because it requires TLS {"network": "tcp", "addr": ":80"}
2026/01/10 20:46:22.950 WARN http HTTP/3 skipped because it requires TLS {"network": "tcp", "addr": ":80"}
2026/01/10 20:46:22.950 INFO http.log server running {"name": "php", "protocols": ["h1", "h2", "h3"]}
2026/01/10 20:46:22.951 INFO Caddy serving PHP app on :80
2026/01/10 20:46:22.953 INFO tls storage cleaning happened too recently; skipping for now {"storage": "FileStorage:C:\\Users\\m\\AppData\\Roaming\\Caddy", "instance": "489ade52-21ab-40c6-b18a-2932fb8eab4d", "try_again": "2026/01/11 20:46:22.953", "try_again_in": 86400}
2026/01/10 20:46:22.953 INFO tls finished cleaning storage units
❯❯ frankenphp git:(windows) 21:46Text files like an index.html page are served just fine. Only when php is attempted to be executed does the program simply stop. |
|
I didn't try the |
|
Could you also show me the content of your PHP script? |
|
Content of the php script: <?php
echo phpinfo();I haven't ran the test suite yet, but |
|
Here is a build I created locally: https://drive.google.com/file/d/1B09de1rERpRUN-bnAje0K2vHcwhVoDJa/view?usp=sharing On my computer, it runs Symfony without issue @henderkes. |
|
Thanks, I'll try this one and report back. Edit: it's working, but it was linked against 8.5.3-dev. I'll try to link against 8.5.1 again and see if I can get anywhere after the new commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request implements Windows support for FrankenPHP, enabling it to compile and run on Windows platforms using Visual Studio's LLVM/Clang toolchain. The changes include platform-specific build configurations, cross-platform path handling improvements, header file reorganization for Windows compatibility, and conditional compilation of features not yet supported on Windows (like CLI mode).
Changes:
- Added Windows-specific CGO flags, header includes, and preprocessor definitions
- Improved cross-platform file path handling using filepath.Join and platform-aware separators
- Moved CLI functionality to Unix-only builds with proper build tags
- Updated watcher library dependency and adjusted import paths
Reviewed changes
Copilot reviewed 31 out of 34 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| frankenphp.h | Added Windows-specific headers, defines, and IntSafe function implementations for Clang |
| frankenphp.c | Added Windows-specific conditional compilation for SIGPIPE handling and unistd.h |
| cgo.go | Added Windows-specific CGO CFLAGS and LDFLAGS |
| cli.go | Moved CLI execution functions to Unix-only build with //go:build !windows tag |
| cli_test.go | Moved CLI tests to Unix-only build |
| frankenphp.go | Removed CLI functions (moved to cli.go) |
| frankenphp_test.go | Removed CLI tests (moved to cli_test.go) |
| watcher_test.go | Fixed file path construction to use filepath.Join for cross-platform compatibility |
| scaling_test.go | Updated path construction to use filepath.Join (with bug: leading slash) |
| phpmainthread_test.go | Updated path construction to use filepath.Join |
| internal/watcher/pattern.go | Added Windows volume name handling and platform-aware path separators |
| internal/watcher/pattern_test.go | Added path normalization helpers and updated import path (needs fix) |
| internal/testext/exttest.go | Added Windows-specific CGO flags (with hard-coded paths) |
| internal/testext/extensions.c | Added frankenphp.h include for Windows compatibility |
| internal/testext/extension.h | Added frankenphp.h include for Windows compatibility |
| internal/testcli/main.go | Added //go:build !windows tag |
| internal/extgen/utils_test.go | Added Windows-specific file permission handling |
| internal/extgen/stub_test.go | Added Windows line ending handling (CRLF vs LF) |
| internal/cpu/cpu_windows.go | Fixed unused parameter with underscore |
| internal/cpu/cpu_unix.go | Added //go:build unix tag |
| types.h | Reordered includes to have frankenphp.h first for Windows compatibility |
| phpmainthread.go | Reordered includes for consistency |
| mercure.go | Added frankenphp.h include |
| cgi.go | Reordered includes for consistency |
| ext.go | Uncommented frankenphp.h include |
| scaling.go | Removed unused C imports |
| testdata/session.php | Changed PHP_EOL to "\n" for consistency |
| go.mod, go.sum | Updated watcher dependency to new module path |
| caddy/go.mod, caddy/go.sum | Updated watcher dependency to new module path |
| caddy/frankenphp/main.go | Removed direct caddy-cbrotli import |
| caddy/frankenphp/cbrotli.go | Added conditional cbrotli import with //go:build !nobrotli |
| caddy/php-cli.go | Added //go:build !windows tag |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Okay, I guess I figured it out? When I move it into the php folder it works, so I'm guessing php is trying to load something in the background but silently fails. Extensions would come to mind, but I'm not loading any. |
Closes #83 #880 #1286.
Working patch for Windows support.
Supports linking to the official PHP release (TS version).
Includes some work from #1286 (thanks @TenHian!!)
This patch allows using Visual Studio to compile the cgo code. To do so, it must be compiled with Go 1.26 (RC) with the following setup:
TODO: